import request from "@/utils/request"
import { Message, Logger, check, MessageType, EventType } from "mirai-ts";

/**
 * 查询方法
 */
async function findWowsUser(server:String,nick:string){
  
  let messageChain: MessageType.MessageChain = [] 
  await request.get('/wowsInfoToBot/findWowsUser',{
    server:server,
    nick:nick
  }).then((response:any) => {
    messageChain.push(Message.Plain(`\n[${response.tag}]${response.nickname}`));
    messageChain.push(Message.Plain(`\n最后战斗 ${response.lastBattleTime}`));
    
    messageChain.push(Message.Plain(`\n=============`));
    messageChain.push(Message.Plain(`\n场次 ${response.fightingNum}`));
    messageChain.push(Message.Plain(`\n胜利 ${response.winningProbability}`));
    messageChain.push(Message.Plain(`\nK/D ${response.killRatio}`));
    messageChain.push(Message.Plain(`\n经验 ${response.expexperience}`));
    messageChain.push(Message.Plain(`\n场均 ${response.aveDamage}`));
    messageChain.push(Message.Plain(`\n命中 ${response.hitRate}`));
    messageChain.push(Message.Plain(`\n======单野====== `));
    messageChain.push(Message.Plain(`\n场次 ${response.soloFightingNum}`));
    messageChain.push(Message.Plain(`\n胜利 ${response.soloWinningProbability}`));
    messageChain.push(Message.Plain(`\n======自行车====== `));
    messageChain.push(Message.Plain(`\n场次 ${response.doubleFightingNum}`));
    messageChain.push(Message.Plain(`\n胜利 ${response.doubleWinningProbability}`));
    messageChain.push(Message.Plain(`\n======装甲车====== `));
    messageChain.push(Message.Plain(`\n场次 ${response.threeFightingNum}`));
    messageChain.push(Message.Plain(`\n胜利 ${response.threeWinningProbability}`));
  }).catch(error=>{
    messageChain.push(Message.Plain(`\n找不到这人`));
  });
  return messageChain
}

/**
 * 单船查询
 */
async function findWowsUserShipByTypeGrade(server:String,nick:string,shipType:String,shipGrade:String){
  
  let messageChain: MessageType.MessageChain = [] 
  await request.get('/wowsInfoToBot/findWowsUserShipByTypeGrade',{
    server:server,
    nick:nick,
    shipType:shipType,
    shipGrade:shipGrade
  }).then((response:any) => {
    messageChain.push(Message.Plain(`\n${nick}`));
    for(let data of response.data){
      messageChain.push(Message.Plain(`\n======${data.shipName}======`));
      messageChain.push(Message.Plain(`\n场次 ${data.fightingNum}`));
      messageChain.push(Message.Plain(`\n胜利 ${data.winningProbability}`));
      messageChain.push(Message.Plain(`\nK/D ${data.killRatio}`));
      messageChain.push(Message.Plain(`\n经验 ${data.expexperience}`));
      messageChain.push(Message.Plain(`\n场均 ${data.aveDamage}`));
      messageChain.push(Message.Plain(`\n命中 ${data.hitRate}`));
    }
    
  }).catch(error=>{
    messageChain.push(Message.Plain(`\n找不到数据`));
  });
  return messageChain
}
export { findWowsUser , findWowsUserShipByTypeGrade};